package com.atguigu.day06;

public class Test02 {
    public static void main(String[] args) {
        GraphicTools g1 = new GraphicTools();
        g1.printRectangle();
        g1.printRectangle(6, 5, "X");
        System.out.println("getTriangleArea(3, 4):" + g1.getTriangleArea(3, 4));
        System.out.println("g1.getTriangleArea(3, 4, 5):" + g1.getTriangleArea(3, 4, 5));
    }
}

class GraphicTools {
    void printRectangle() {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++)
                System.out.print("*");
            System.out.println();
        }
    }

    void printRectangle(int line, int column, String sign) {
        for (int i = 0; i < line; i++) {
            for (int j = 0; j < column; j++)
                System.out.print(sign);
            System.out.println();
        }
    }

    double getTriangleArea(double base, double height) {
        return base * height * 0.5;
    }

    double getTriangleArea(double a, double b, double c) {
        if (a + b < c || a + c < b || b + c < a) {
            return 0.0;
        } else {
            double d = (a + b + c) / 2;
            return Math.sqrt((d * (d - a) * (d - b) * (d - c)));
        }
    }
}
